<script setup lang="ts">
import { showConfirmDialog } from 'vant'
import { useRouter } from 'vue-router';

defineOptions({
  name: 'My',
})

const router = useRouter()

const exitFn = () => {
  showConfirmDialog({
    title: '温馨提示',
    message: '您确定要退出登录吗?',
  })
    .then(() => {
      router.push('/login')
    })
    .catch(() => {
      // on cancel
    })
}
</script>

<template>
  <header class="header">
    <img
      src="https://mushroom-front.oss-cn-shanghai.aliyuncs.com/banner/carousel-img04.jpg"
      alt=""
    />
    <div class="right">
      <p class="nickname">蘑菇爱好者</p>
      <p class="desc">来自武汉，喜爱各种蘑菇...</p>
    </div>
  </header>
  <footer class="footer">
    <h1>快捷工具</h1>
    <ul>
      <li>
        <span>修改资料</span>
        <van-icon name="arrow" />
      </li>
      <li>
        <span>上传蘑菇</span>
        <van-icon name="arrow" />
      </li>
    </ul>
  </footer>
  <div class="exit">
    <van-button type="warning" @click="exitFn">退出登录</van-button>
  </div>
</template>

<style scoped lang="less">
.header {
  height: 200px;
  background-image: linear-gradient(to bottom, #6cbbe8, white);
  box-sizing: border-box;

  display: flex;
  gap: 24px;
  padding: 50px 24px;

  img {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
  }

  .right {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;

    p {
      font-size: 18px;
    }

    .nickname {
      width: max-content;
      color: transparent;
      background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      background-clip: text;
      -webkit-background-clip: text;
    }

    .desc {
      font-size: 14px;
      color: #8d8c8c;
    }
  }
}

.footer {
  min-height: 300px;
  margin: 8px 16px;
  padding: 12px;
  border-radius: 6px;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.1);

  h1 {
    font-weight: 600;
    font-size: 18px;
  }

  ul {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  li {
    width: 100%;
    height: 50px;
    line-height: 50px;
    font-size: 16px;

    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-right: 8px;

    &:not(:last-child) {
      border-bottom: 1px solid #faf8f8;
    }
  }
}

.exit {
  box-sizing: border-box;
  margin: 0 16px;

  .van-button {
    width: 100%;
  }
}
</style>
